home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / rhstdlib.arc / TEST.ASM < prev    next >
Assembly Source File  |  1990-10-20  |  28KB  |  1,620 lines

  1. ;****************************************************************************
  2. ;
  3. ; T  E  S  T       S  U  I  T  E      F  O  R   
  4. ;
  5. ;
  6. ; R  A  N  D  Y      H  Y  D  E ' S     S  T  A  N  D  A  R  D
  7. ;
  8. ; L  I  B  R  A  R  Y     F  O  R     A  S  S  E  M  B  L  Y   
  9. ;
  10. ; L  A  N  G  U  A  G  E     P  R  O  G  R  A  M  M  E  R  S
  11. ;
  12. ;****************************************************************************
  13. ;
  14. ;
  15. ; Global variables go here:
  16. ;
  17. dseg        segment    para public 'data'
  18. i        dw    -4321
  19. pi        dd    i
  20. u        dw    2345
  21. pu        dd    u
  22. l        dd    -1234567890
  23. pl        dd    l
  24. ul        dd    987654321
  25. pul        dd    ul
  26. ;
  27. ps        dd    s
  28. s        db    "Printf string",0
  29. TestString0    db    "This string gets printed by puts!",cr,lf,0
  30. TestString1    db    "This string gets used by the STRxxx Routines",cr,lf,0
  31. TestString2    db    "gets",0
  32. TestString3    db    "Hello there",0
  33. TestString4    db    "THIS STRING GETS USED BY THE STRXXX ROUTINES",cr,lf,0
  34. TestString5    db    "all lower case",cr,lf,0
  35. TestString6    db    "Clear out this string",0
  36. StringSet1    db    "Tabcdefghijklmnopqrst ",0
  37. StringSet2    db    "uvwxyz!",0
  38. buffer        db    256 dup (?)
  39. buffer2        db    256 dup (?)
  40. sfstr1        db    "1 -1 1 65000 100000 -100000 1 4000000000 0abc x",0
  41. sfstr2        db    "1, 2",0
  42. hex1        db    "12ab",0
  43. int1        db    "-12345",0
  44. int2        db    "65000",0
  45. lint1        db    "-2000000000",0
  46. lint2        db    "4000000000",0
  47. i1        dw    ?
  48. i2        dw    ?
  49. u1        dw    ?
  50. u2        dw    ?
  51. l1        dd    ?
  52. l2        dd    ?
  53. ul1        dd    ?
  54. ul2        dd    ?
  55. h1        dw    ?
  56. c1        db    ?
  57. c2        db    '!'
  58. MemAvail    dw    ?
  59. ;
  60. ; Allocate some character sets down here
  61. ;
  62.         set    charset, cs2, cs3, cs4
  63. ;
  64. dseg        ends
  65. ;
  66. ;
  67. ;
  68. ;
  69. cseg        segment    para public 'code'
  70.         assume    cs:cseg, ds:dseg
  71. ;
  72.         include    stdlib.a
  73. ;
  74. lesi        macro    adrs
  75.         mov     di, seg adrs
  76.         mov    es, di
  77.         lea    di, adrs
  78.         endm
  79. ;
  80. ldxi        macro    adrs
  81.         mov    dx, seg adrs
  82.         lea    si, adrs
  83.         endm
  84. ;
  85. ; Variables that wind up being used by the standard library routines.
  86. ; The MemInit routine uses "PSP" and "zzzzzzseg" labels.  They must be
  87. ; present if you intend to use getenv, MemInit, malloc, and free.
  88. ;
  89. ;
  90.         public    PSP
  91. PSP        dw    ?
  92. ;
  93. cr        equ    13
  94. lf        equ    10
  95. ;
  96. ;
  97. ; Main is the main program.  Program execution always begins here.
  98. ;
  99. Main        proc
  100.         mov    cs:PSP, es        ;Save pgm seg prefix
  101.         mov    ax, seg dseg        ;Set up the segment registers
  102.         mov    ds, ax
  103.         mov    es, ax
  104.         mov    dx, 0            ;Allocate all available RAM.
  105.         MemInit
  106.         mov    MemAvail, cx
  107.         printf
  108.         db    "There are %x paragraphs of memory available."
  109.         db    cr,lf,lf,0
  110.         dd    MemAvail
  111. ;
  112. ;
  113. ;
  114. ;
  115. ;***************************************************************************
  116. ;
  117. ; Test the character set routines down here:
  118. ;
  119.         print  
  120.         db    "Testing RangeSet:",cr,lf,0
  121.         mov    al, 'A'
  122.         mov    ah, 'F'
  123.         lesi    CharSet
  124.         rangeset
  125.         print
  126.         db    "Chars in set: ",0
  127.         call    PrintSet
  128. ;
  129.         print
  130.         db    cr,lf,lf,"Testing addstr, addstrl:",cr,lf,0
  131.         lesi    cs2
  132.         ldxi    StringSet2
  133.         addstr
  134.         addstrl
  135.         db    "aAbBcCdDeEfF",0
  136.         print
  137.         db    "Chars in set: ",0
  138.         call    PrintSet
  139. ;
  140.         print
  141.         db    cr,lf,lf,"Testing rmvstr, rmvstrl:",cr,lf,0
  142.         lesi    cs2
  143.         ldxi    StringSet2
  144.         rmvstr
  145.         rmvstrl
  146.         db    "ABCDEF",0
  147.         print
  148.         db    "Chars in set: ",0
  149.         call    PrintSet
  150. ;
  151.         print
  152.         db    cr,lf,lf,"Testing addchar/rmvchar:",cr,lf,0
  153.         lesi    cs2
  154.         mov    al, 'A'
  155.         addchar
  156.         mov    al, 'a'
  157.         rmvchar
  158.         print
  159.         db    "Chars in set: ",0
  160.         call    PrintSet
  161. ;
  162.         print
  163.         db    cr,lf,lf,"Testing emptyset:",cr,lf,0
  164.         emptyset
  165.         print
  166.         db    "Chars in set: ",0
  167.         call    PrintSet
  168. ;
  169.         print
  170.         db    cr,lf,lf,"Testing member:",cr,lf,0
  171.         addstrl
  172.         db    "ABCDEF",0
  173.         mov    al, 'A'
  174.         member
  175.         jne    NotInSet1
  176.         print
  177.         db    "A was not in the set",0
  178.         jmp    short NIS1
  179. ;
  180. NotInSet1:    print
  181.         db    "A is in the set",0
  182. NIS1:        putcr
  183.         mov    al, "G"
  184.         member
  185.         jne    NotInSet2
  186.         print
  187.         db    "G is not in the set",0
  188.         jmp    short NIS2
  189. ;
  190. NotInSet2:    print
  191.         db    "G is in the set",0
  192. NIS2:        putcr
  193. ;
  194.         print
  195.         db    cr,lf,lf,"Testing copyset:",cr,lf,0
  196.         mov    dx, es
  197.         mov    si, di
  198.         lesi    cs3
  199.         copyset
  200.         print
  201.         db    "Value in cs3: ",0
  202.         call    Printset
  203. ;
  204.         print    
  205.         db    cr,lf,lf,"Testing unionset:",cr,lf,0
  206.         addstrl
  207.         db    "ABCDEFuvwxyz",0
  208.         ldxi    cs2
  209.         setunion
  210.         print
  211.         db    "Chars in set: ",0
  212.         call    Printset
  213. ;
  214.         print
  215.         db    cr,lf,lf,"Testing set difference",cr,lf,0
  216.         ldxi    cs2
  217.         setdifference
  218.         print
  219.         db    "Chars in set: ",0
  220.         call    PrintSet
  221. ;
  222. ;
  223. ;
  224. ;***************************************************************************
  225. ;
  226. ; Test the STRxxx routines here.
  227. ;
  228. ;
  229. ;*Strspan
  230. ;
  231.         print
  232.         db    cr,lf,lf,"Testing strspan:",cr,lf,0
  233. ;
  234.         lesi    TestString1
  235.         ldxi    StringSet1
  236.         strspan
  237.         mov    i1, cx
  238.         printf
  239.         db    "TestString1 contains a character not found in "
  240.         db    "StringSet1 at position %d\n\n",0
  241.         dd    i1
  242. ;
  243. ;
  244. ;*Strspanl
  245. ;
  246.         print
  247.         db    "Testing strspanl:",cr,lf,0
  248. ;
  249.         lesi    TestString1
  250.         strspanl
  251.         db    "Tabcdefghijklmnopqrst ",0
  252.         mov    i1, cx
  253.         printf
  254.         db    "TestString1 contains a character not found in "
  255.         db    "the set at position %d\n\n",0
  256.         dd    i1
  257. ;
  258. ;
  259. ;*Strcspan
  260. ;
  261.         print
  262.         db    "Testing strcspan:",cr,lf,0
  263. ;
  264.         lesi    TestString1
  265.         ldxi    StringSet2
  266.         strcspan
  267.         mov    i1, cx
  268.         printf
  269.         db    "TestString1 contains a character found in "
  270.         db    "StringSet2 at position %d\n\n",0
  271.         dd    i1
  272. ;
  273. ;
  274. ;*Strcspanl
  275. ;
  276.         print
  277.         db    "Testing strcspanl:",cr,lf,0
  278. ;
  279.         lesi    TestString1
  280.         strcspanl
  281.         db    "uvwxyz!",0
  282.         mov    i1, cx
  283.         printf
  284.         db    "TestString1 contains a character not found in "
  285.         db    "the set at position %d\n\n",0
  286.         dd    i1
  287. ;
  288. ;
  289. ;*Strset, Strset2
  290. ;
  291.         print
  292.         db    "Testing Strset",cr,lf,0
  293. ;
  294.         lesi    TestString6
  295.         mov    al, '*'
  296.         strset
  297.         puts
  298. ;
  299. ;
  300.         print
  301.         db    cr,lf,lf,"Testing StrSet2:",cr,lf,0
  302.         mov    cx, 32
  303.         mov    al, '#'
  304.         strset2
  305.         puts
  306.         free
  307.         putcr
  308.         putcr
  309. ;
  310. ;
  311. ;*Strupr, Strupr2
  312. ;
  313.         printf
  314.         db    "Testing Strupr:\n"
  315.         db    "Before: %s",0
  316.         dd    TestString5
  317.         lesi    TestString5
  318.         strupr
  319.         printf
  320.         db    "After: %s",0
  321.         dd    TestString5
  322. ;
  323. ;
  324. ;*Strlwr, Strlwr2
  325. ;
  326.         printf
  327.         db    cr,lf,"Testing Strlwr:\n"
  328.         db    "Before: %s",0
  329.         dd    TestString5
  330.         lesi    TestString5
  331.         strlwr
  332.         printf
  333.         db    "After: %s",0
  334.         dd    TestString5
  335. ;
  336. ;
  337. ;
  338. ;*Strcmp, Strcmpl
  339. ;
  340.         print
  341.         db    "Testing Strcmp",cr,lf,0
  342. ;
  343.         lesi    TestString1
  344.         ldxi    TestString1
  345.         strcmp
  346.         jne    Sne1
  347.         print
  348.         db    "TestString1 == TestString1",cr,lf,0
  349.         jmp    short s2
  350. ;
  351. Sne1:        print
  352.         db    "TestString1 <> TestString1",cr,lf,0
  353. ;
  354. s2:        ldxi    TestString0
  355.         strcmp
  356.         jb    IsBelow
  357.         ja    IsAbove
  358.         printf
  359.         db    "'%s' is equal to '%s'\n",0
  360.         dd    TestString1, TestString0
  361.         jmp    short s3
  362. ;
  363. IsBelow:    printf
  364.         db    "%s is less than \n%s\n",0
  365.         dd    TestString1, TestString0
  366.         jmp    short s3
  367. ;
  368. IsAbove:    printf
  369.         db    "%s is greater than \n%s\n",0
  370.         dd    TestString1, TestString0
  371. ;
  372. S3:
  373. ;
  374.         print
  375.         db    cr,lf,"Testing Strcmpl",cr,lf,0
  376. ;
  377.         lesi    TestString2
  378.         strcmpl
  379.         db    "gets",0
  380.         jne    Sne1a
  381.         print
  382.         db    "TestString2 == 'gets'",cr,lf,0
  383.         jmp    short s2a
  384. ;
  385. Sne1a:        print
  386.         db    "TestString2 <> 'gets'",cr,lf,0
  387. ;
  388. s2a:        lesi    TestString2
  389.         strcmpl
  390.         db    "itsa",0
  391.         jb    IsBelowa
  392.         ja    IsAbovea
  393.         printf
  394.         db    "'%s' is equal to 'itsa'\n",0
  395.         dd    TestString2
  396.         jmp    short s3a
  397. ;
  398. IsBelowa:    printf
  399.         db    "'%s' is less than 'itsa'\n",0
  400.         dd    TestString2
  401.         jmp    short s3a
  402. ;
  403. IsAbovea:    printf
  404.         db    "'%s' is greater than 'itsa'\n",0
  405.         dd    TestString2
  406. ;
  407. S3a:
  408. ;
  409. ;
  410. ;*Stricmp, Stricmpl
  411. ;
  412.         print
  413.         db    cr,lf,"Testing Stricmp",cr,lf,0
  414. ;
  415.         lesi    TestString1
  416.         ldxi    TestString4
  417.         stricmp
  418.         jne    Sne1c
  419.         print
  420.         db    "TestString1 == TestString4",cr,lf,0
  421.         jmp    short s2c
  422. ;
  423. Sne1c:        print
  424.         db    "TestString1 <> TestString4",cr,lf,0
  425. ;
  426. s2c:        lesi    TestString1
  427.         ldxi    TestString4
  428.         stricmp
  429.         jb    IsBelowc
  430.         ja    IsAbovec
  431.         printf
  432.         db    "'%s' is equal to '%s'\n",0
  433.         dd    TestString1, TestString4
  434.         jmp    short s3c
  435. ;
  436. IsBelowc:    printf
  437.         db    "'%s' is less than '%s'\n",0
  438.         dd    TestString1, TestString4
  439.         jmp    short s3c
  440. ;
  441. IsAbovec:    printf
  442.         db    "'%s' is greater than '%s'\n",0
  443.         dd    TestString1, TestString4
  444. ;
  445. S3c:
  446. ;
  447. ;
  448.         print
  449.         db    "Testing Stricmpl",cr,lf,0
  450. ;
  451.         lesi    TestString2
  452.         stricmpl
  453.         db    "GETS",0
  454.         jne    Sne1d
  455.         print
  456.         db    "TestString2 == 'gets'",cr,lf,0
  457.         jmp    short s2d
  458. ;
  459. Sne1d:        print
  460.         db    "TestString2 <> 'gets'",cr,lf,0
  461. ;
  462. s2d:        lesi    TestString2
  463.         strcmpl
  464.         db    "itsa",0
  465.         jb    IsBelowd
  466.         ja    IsAboved
  467.         printf
  468.         db    "'%s' is equal to 'itsa'\n",0
  469.         dd    TestString2
  470.         jmp    short s3d
  471. ;
  472. IsBelowd:    printf
  473.         db    "'%s' is less than 'itsa'\n",0
  474.         dd    TestString2
  475.         jmp    short s3d
  476. ;
  477. IsAboved:    printf
  478.         db    "'%s' is greater than 'itsa'\n",0
  479.         dd    TestString2
  480. ;
  481. S3d:
  482. ;
  483. ;
  484. ;*Strcpy
  485. ;
  486.         lesi    TestString1
  487.         ldxi    Buffer
  488.         strcpy
  489.         puts
  490. ;
  491. ;*Strcpyl
  492. ;
  493.         print
  494.         db    "Testing Strcpyl:",cr,lf,0
  495. ;
  496.         ldxi    Buffer
  497.         strcpyl
  498.         db    "This is an strcpyl string",cr,lf,0
  499.         puts
  500.         ldxi    Buffer2
  501.         strcpy
  502.         puts
  503. ;
  504. ;*Strdup
  505. ;
  506.         lesi    TestString1
  507.         strdup          
  508.         puts
  509.         free
  510. ;
  511. ;*Strdupl
  512. ;
  513.         print
  514.         db    "Testing Strdupl:",cr,lf,0
  515. ;
  516.         strdupl
  517.         db    "This string is for strdupl",cr,lf,0
  518.         puts
  519.         free
  520. ;
  521. ;*Strlen
  522. ;
  523.         lesi    s
  524.         strlen
  525.         mov    i1, cx
  526.         printf
  527.         db    "Length of string: '%s' is %d\n",0
  528.         dd    s, i1
  529. ;
  530. ;*Strcat
  531. ;
  532.         print
  533.         db      "Testing strcat:",cr,lf,0
  534. ;
  535.         lesi    Buffer
  536.         strcpyl
  537.         db    "Test String 1 --",0
  538.         ldxi    TestString1
  539.         strcat
  540.         puts
  541. ;
  542. ;*Strcatl
  543. ;
  544.         print
  545.         db      "Testing strcatl:",cr,lf,0
  546. ;
  547.         lesi    Buffer
  548.         strcpyl
  549.         db    "Strcatl test --",0
  550.         strcatl
  551.         db    "More stuff for Strcatl",cr,lf,0
  552.         puts
  553. ;
  554. ;*Strcat2
  555. ;
  556.         print
  557.         db    "Testing strcat2:",cr,lf,0
  558. ;
  559.         lesi    TestString1
  560.         ldxi    TestString0
  561.         strcat2
  562.         puts
  563.         free
  564. ;
  565.         print
  566.         db    "Testing strcat2l:",cr,lf,0
  567. ;
  568.         lesi    TestString1
  569.         strcat2l
  570.         db    "Appended string",cr,lf,0
  571.         puts
  572.         free
  573. ;
  574. ;*Strchar
  575. ;                     
  576.         lesi    TestString1
  577.         mov    al, 'a'
  578.         StrChr
  579.         pushf
  580.         mov    i1, cx
  581.         printf
  582.         db    "Testing strchr:",cr,lf
  583.         db    "Searching for 'a' in '%s'\n"
  584.         db    "Found it at position %d\n",0
  585.         dd    TestString1, i1
  586.         popf
  587.         jnc    FndIt1
  588.         print
  589.         db    "Could not find character in string.",cr,lf,0
  590. ;
  591. FndIt1:        lesi    TestString1
  592.         mov    al, 'T'
  593.         StrChr
  594.         pushf
  595.         mov    i1, cx
  596.         printf
  597.         db    "Testing strchr:",cr,lf
  598.         db    "Searching for 'T' in '%s'\n"
  599.         db    "Found it at position %d\n",0
  600.         dd    TestString1, i1
  601.         popf
  602.         jnc    FndIt2
  603.         print
  604.         db    "Could not find character in string.",cr,lf,0
  605. FndIt2:
  606. ;
  607. ;
  608. ;*Strstr
  609. ;
  610.         print
  611.         db    "Testing strstr:",cr,lf,0
  612. ;
  613.         lesi    TestString1
  614.         ldxi    TestString2
  615.         strstr
  616.         jc    NotFnd2
  617.         mov    i1, cx
  618.         printf
  619.         db    "Found substring at position %i\n",0
  620.         dd    i1
  621.         jmp    short FndIt3
  622. ;
  623. NotFnd2:    print
  624.         db    "Didn't find substring #1.",cr,lf,0
  625. ;
  626. FndIt3:        ldxi    TestString3
  627.         strstr
  628.         jc    NotFnd3
  629.         print
  630.         db    "Error, found a string which isn't present!",cr,lf,0
  631. ;
  632. NotFnd3:
  633. ;
  634. ;
  635. ;*Strstrl
  636. ;
  637.         print
  638.         db    "Testing strstrl:",cr,lf,0
  639. ;
  640.         lesi    TestString1
  641.         strstrl
  642.         db    "gets",0
  643.         jc    NotFnd2a
  644.         mov    i1, cx
  645.         printf
  646.         db    "Found substring at position %i\n",0
  647.         dd    i1
  648.         jmp    short FndIt3a
  649. ;
  650. NotFnd2a:    print
  651.         db    "Didn't find substring #1.",cr,lf,0
  652. ;
  653. FndIt3a:    strstrl
  654.         db    "Hello There",0
  655.         jc    NotFnd3a
  656.         print
  657.         db    "Error, found a string which isn't present!",cr,lf,0
  658. ;
  659. NotFnd3a:
  660. ;     
  661. ;
  662. ;
  663. ;
  664.         putcr
  665.         putcr
  666. ;
  667. ;***************************************************************************
  668. ;
  669. ; Test IsAlNum, IsDigit, IsAlpha, IsLower, IsUpper, and IsxDigit here:
  670. ;
  671.         print
  672.         db    "Testing IsAlNum, IsDigit, IsAlpha, IsLower, "
  673.         db    "IsUpper, and IsXDigit",cr,lf,0
  674. ;
  675.         mov    cx, 26
  676.         mov    al, 'Z'
  677.         mov    ah, 'z'
  678. TstAlphaLp:    IsAlNum
  679.         jne    yALNumFail
  680.         IsAlpha
  681.         jne    ALFail
  682.         IsUpper
  683.         jne    UprFail
  684.         cmp    al, 'F'
  685.         ja    NotHex
  686.         IsXDigit
  687.         jne    XFail
  688. ;
  689. NotHex:        xchg    al, ah
  690.         IsAlNum
  691. yALNumFail:    jne    AlNumFail
  692.         IsAlpha
  693.         jne    ALFail
  694.         IsLower
  695.         jne    LwrFail
  696.         cmp    al, 'f'
  697.         ja    NotHex2
  698.         IsXDigit
  699.         jne    XFail
  700. ;
  701. NotHex2:    xchg    al, ah
  702.         dec    al
  703.         dec    ah
  704.         loop    TstAlphaLp
  705. ;
  706.         mov    cx, 10
  707.         mov    al, '9'
  708. TstDigLp:    IsDigit
  709.         jne    DigitFail
  710.         IsAlNum
  711.         jne    AlNumFail
  712.         IsXDigit
  713.         jne    XFail
  714.         dec    al
  715.         loop    TstDigLp
  716.         jmp    short TestBad
  717. ;
  718. ALNumFail:    jmp    short xALNumFail
  719. ALFail:        jmp    short xALFail
  720. UprFail:    jmp    xUprFail
  721. LwrFail:    jmp    xLwrFail
  722. XFail:        jmp    xXFail
  723. DigitFail:    jmp    xDigitFail
  724. ;
  725. TestBad:    mov    al, '1'
  726.         IsAlpha
  727.         je    ALFail
  728.         IsLower
  729.         je    LwrFail
  730.         IsUpper
  731.         je    UprFail
  732.         mov    al, '!'
  733.         IsDigit
  734.         je    DigitFail
  735.         IsAlNum
  736.         je    AlNumFail
  737.         IsXDigit
  738.         je    XFail
  739.         jmp    TestSPrintf
  740. ;
  741. xALNumFail:    print
  742.         db    "IsALNum has failed",cr,lf,0
  743.         jmp    TestSPrintf
  744. ;
  745. xALFail:    print
  746.         db    "IsAlpha has failed",cr,lf,0
  747.         jmp    short TestSPrintf
  748. ;
  749. xUprFail:    print
  750.         db    "IsUpper has failed",cr,lf,0
  751.         jmp    short TestSPrintf
  752. ;
  753. xLwrFail:    print
  754.         db    "IsLower has failed",cr,lf,0
  755.         jmp    short TestSPrintf
  756. ;
  757. xXFail:        print
  758.         db    "IsXDigit has failed",cr,lf,0
  759.         jmp    short TestSPrintf
  760. ;
  761. xDigitFail:    print
  762.         db    "IsDigit has failed",cr,lf,0
  763. ;
  764. ;***************************************************************************
  765. ;
  766. ; Testing sprintf and sbprintf here.
  767. ;
  768. TestSPrintf:    sprintf
  769.         db    "I= %i, I='%10i', I=%^i",cr,lf
  770.         db    "U= %u",cr,lf,0
  771.         dd    i,i,pi,u
  772.         puts
  773.         free
  774. ;
  775.         lesi    Buffer
  776.         sbprintf
  777.         db    "I= %i, I='%10i', I=%^i",cr,lf
  778.         db    "U= %u",cr,lf,0
  779.         dd    i,i,pi,u
  780.         puts
  781. ;
  782. ;***************************************************************************
  783. ;
  784. ; Testing various ITOxx routines here.
  785. ;
  786.         mov    ax, -1234
  787.         itoa
  788.         print
  789.         db    "ITOA: -1234 is ",0
  790.         puts
  791.         putcr
  792.         free            ;Free allocated storage.
  793. ;
  794. ;-----
  795. ;
  796.         mov    ax, 43210
  797.         utoa
  798.         print
  799.         db    "UTOA: 43210 is ",0
  800.         puts
  801.         putcr
  802.         free            ;Free allocated storage.
  803. ;
  804. ;-----
  805. ;
  806.         mov    ax, 0ABCDh
  807.         htoa
  808.         print
  809.         db    "HTOA: 0cdh is ",0
  810.         puts
  811.         putcr
  812.         free            ;Free allocated storage.
  813. ;
  814. ;-----
  815. ;
  816.         mov    ax, 0ABCDh
  817.         wtoa
  818.         print
  819.         db    "WTOA: 0abcdh is ",0
  820.         puts
  821.         putcr
  822.         free            ;Free allocated storage.
  823. ;
  824. ;-----
  825. ;
  826.         mov    ax, -1234
  827.         mov    dx, 0ffffh
  828.         ltoa
  829.         print
  830.         db    "LTOA: -1234 is ",0
  831.         puts
  832.         putcr
  833.         free
  834. ;
  835. ;-----
  836. ;
  837.         mov    ax, 1234
  838.         mov    dx, 0
  839.         ultoa
  840.         print
  841.         db    "ULTOA: 1234 is ",0
  842.         puts
  843.         putcr
  844.         free
  845. ;
  846. ;
  847. ;***************************************************************************
  848. ;
  849. ; Testing memory management routines here:
  850. ;
  851.         mov    cx, 256
  852.         malloc
  853.         IsPtr
  854.         jnc    ValidPtr
  855.         print
  856.         db    "This is not a valid ptr (1)",cr,lf,0
  857.         jmp    short x1
  858. ;
  859. ValidPtr:    print
  860.         db    "Malloc returned a valid ptr",cr,lf,0
  861. ;
  862. x1:        inc    di
  863.         IsPtr
  864.         jc    InvalidPtr
  865.         print
  866.         db    "Incrementing a pointer didn't make it invalid",cr,lf,0
  867.         jmp    short x2
  868. ;
  869. InvalidPtr:    print
  870.         db    "Incrementing a pointer makes it invalid",cr,lf,0
  871. ;
  872. x2:        IsInHeap
  873.         jc    BadIsIn
  874.         print
  875.         db    "Although incrementing it leaves it in the heap",cr,lf,0
  876.         jmp    short x3
  877. ;
  878. BadIsIn:    print
  879.         db    "Incrementing the pointer moved it out of the heap"
  880.         db    cr,lf,0
  881. ;
  882. x3:        dec    di
  883.         free
  884.         jnc    GoodFree
  885.         print
  886.         db    "Free returned an error",cr,lf,0
  887.         jmp    short x4
  888. ;
  889. GoodFree:    print
  890.         db    "FREE did its job.",cr,lf,0
  891. ;
  892. x4:        mov    cx, 512
  893.         malloc
  894.         mov    cx, 256
  895.         realloc
  896.         jnc    GoodRealloc
  897.         print
  898.         db    "Realloc screwed up!",cr,lf,0
  899.         jmp    x5
  900. ;
  901. GoodRealloc:    DupPtr
  902.         free
  903.         jnc    GF1
  904.         print
  905.         db    "Free choked after DupPtr",cr,lf,0
  906.         jmp    short x5
  907. ;
  908. GF1:        free
  909.         jnc    GF2
  910.         print
  911.         db    "Free choked after second call.",cr,lf,0
  912.         jmp    short x5
  913. ;
  914. GF2:        free
  915.         jc    x5
  916.         print
  917.         db    "Free DIDN'T return an error when it was "
  918.         db    "supposed to.",cr,lf,0
  919. ;
  920. x5:
  921. ;
  922. ;
  923. ;****************************************************************************
  924. ;
  925. ; Testing the ISIZE and LSIZE routines here:
  926. ;
  927.         mov    ax, -12345
  928.         isize
  929.         print
  930.         db    "Size of -12345 (isize) is ",0
  931.         puti
  932.         mov    ax, 1234
  933.         usize
  934.         print
  935.         db    cr,lf,"Size of 1234 (usize) is ",0
  936.         puti
  937. ;
  938.         mov    dx, 0ffffh
  939.         mov    ax, -12345
  940.         lsize
  941.         print
  942.         db    cr,lf,"Size of -12345 (lsize) is ",0
  943.         puti
  944.         mov    ax, 1234
  945.         xor    dx, dx
  946.         ulsize
  947.         print
  948.         db    cr,lf,"Size of 1234 (ulsize) is ",0
  949.         puti
  950.         putcr
  951. ;
  952. ;****************************************************************************
  953. ;
  954. ; Test the "ATOxx" routines here.
  955. ;
  956.         print
  957.         db    "Testing ATOH: ",0
  958.         lesi    hex1
  959.         atoh
  960.         putw
  961.         mov    al, ' '
  962.         putc
  963. ;
  964.         atoh2
  965.         putw
  966.         putcr
  967. ;
  968.         print
  969.         db    "Testing ATOI: ",0
  970.         lesi    int1
  971.         atoi
  972.         puti
  973.         mov    al, ' '
  974.         putc
  975.         atoi2
  976.         puti
  977.         putcr
  978. ;
  979.         print
  980.         db    "Testing ATOU: ",0
  981.         lesi    int2
  982.         atou
  983.         putu
  984.         mov    al, ' '
  985.         putc
  986.         atou2
  987.         putu
  988.         putcr
  989. ;
  990.         print
  991.         db    "Testing ATOL: ",0
  992.         lesi    lint1
  993.         atol
  994.         putl
  995.         mov    al, ' '
  996.         putc
  997.         atol2
  998.         putl
  999.         putcr
  1000. ;
  1001.         print
  1002.         db    "Testing ATOUL: ",0
  1003.         lesi    lint2
  1004.         atoul
  1005.         putul
  1006.         mov    al, ' '
  1007.         putc
  1008.         atoul2
  1009.         putul
  1010.         putcr
  1011. ;
  1012. ;
  1013. ;****************************************************************************
  1014. ;
  1015. ; Test SCANF here:
  1016. ;
  1017.         printf
  1018.         db    "Enter some text: ",0
  1019.         scanf
  1020.         db    "%s",0
  1021.         dd    buffer
  1022.         print
  1023.         db    "You entered: ",0
  1024.         lesi    buffer
  1025.         puts
  1026.         putcr
  1027. ;
  1028. ; Test SSCANF here:
  1029. ;
  1030.         printf
  1031.         db    "Before, c1=%c, c2=%c\n",0
  1032.         dd    c1,c2
  1033. ;
  1034.         lesi    sfstr1
  1035.         sscanf
  1036.         db    "%i %d %u %u %ld %li %lu %lu %x %c",0
  1037.         dd    i1,i2,u1,u2,l1,l2,ul1,ul2,h1,c1
  1038. ;
  1039.         printf
  1040.         db    "Values input by sscanf:\n"
  1041.         db    "i1=%d, i2=%d\n"
  1042.         db    "u1=%u, u2=%u\n"
  1043.         db    "l1=%ld, l2=%ld\n"
  1044.         db    "ul1=%lu, ul2=%lu\n"
  1045.         db    "h1=%x\n"
  1046.         db    "c1=%c,  c2=%c\n"
  1047.         db    0
  1048.         dd    i1,i2,u1,u2,l1,l2,ul1,ul2,h1,c1,c2
  1049. ;
  1050. ;
  1051.         print
  1052.         db    "Testing scanf character skipping:",cr,lf,0
  1053.         lesi    sfstr2
  1054.         sscanf
  1055.         db    "%i, %i",0
  1056.         dd    i1,i2
  1057.         printf
  1058.         db    "i1=%i, i2=%i\n",0
  1059.         dd    i1, i2
  1060. ;
  1061. ;
  1062. ;****************************************************************************
  1063. ;
  1064. ;
  1065. ;
  1066. ; Testing the PUTC routines here.
  1067. ;
  1068. ; The following code should print:
  1069. ;
  1070. ; aaa
  1071. ; aaa
  1072. ; aaa
  1073. ; aaaaaaaa
  1074. ;
  1075. ; aaaa
  1076. ; aaaaaaaa
  1077. ; aaaa
  1078. ;
  1079. ;
  1080.         mov    al, 'a'
  1081.         putc
  1082.         putc
  1083.         putc
  1084. ;
  1085.         putcr
  1086. ;
  1087.         putcstdout
  1088.         putcstdout
  1089.         putcstdout
  1090.         putcr
  1091. ;
  1092.         putcbios
  1093.         putcbios
  1094.         putcbios
  1095.         putcr
  1096. ;
  1097.         mov    di, cs
  1098.         mov    es, di
  1099.         lea    di, dblchars
  1100.         setoutadrs
  1101. ;
  1102.         putc
  1103.         putc
  1104.         putc
  1105.         putc
  1106.         putcr
  1107. ;
  1108.         getoutadrs
  1109.         cmp    di, offset dblchars
  1110.         jne    badtest
  1111.         mov    di, es
  1112.         cmp    di, seg dblchars
  1113.         jne    badtest
  1114. ;
  1115.         mov    di, seg sl_putcstdout
  1116.         mov    es, di
  1117.         lea    di, sl_putcstdout
  1118.         pushoutadrs
  1119.         putc
  1120.         putc
  1121.         putc
  1122.         putc
  1123.         putcr
  1124. ;
  1125.         popoutadrs
  1126.         putc
  1127.         putc
  1128.         putc
  1129.         putc
  1130.         putcr
  1131.         popoutadrs
  1132.         cmp    di, offset dblchars
  1133.         jne    badtest
  1134.         mov    di, es
  1135.         cmp    di, seg dblchars
  1136.         jne    badtest
  1137. ;
  1138.         putc
  1139.         putc
  1140.         putc
  1141.         putc
  1142.         putcr
  1143.         jmp    short goodtest
  1144. ;
  1145. badtest:    print
  1146.         db    "GetOutAdrs or PopOutAdrs did not return "
  1147.         db    "the proper address",cr,lf,0
  1148. ;
  1149. GoodTest:
  1150. ;
  1151. ;
  1152. ;****************************************************************************
  1153. ;
  1154. ; Test the remaining print routines here
  1155. ;
  1156.         print
  1157.         db    "This is a test of the print routine",cr,lf,0
  1158. ;
  1159.         print
  1160.         db    0
  1161. ;
  1162.         print
  1163.         db    "So is this!",cr,lf,0
  1164. ;
  1165.         lesi    TestString0
  1166.         puts
  1167. ;
  1168.         print
  1169.         db    "Hex value 0xfa output by PutH: ",0
  1170.         mov    al, 0fah
  1171.         puth
  1172. ;
  1173.         print
  1174.         db    cr,lf,"Hex value 0xfa12 output by PutW: ",0
  1175.         mov    ax, 0fa12h
  1176.         putw
  1177. ;
  1178.         print
  1179.         db    cr,lf,"Decimal value 0xffff output by puti: ",0
  1180.         mov    ax, 0ffffh
  1181.         puti
  1182.         print    
  1183.         db    cr,lf,"Decimal value 1 output by puti: ",0
  1184.         mov    ax, 1
  1185.         puti
  1186. ;
  1187.         print
  1188.         db    cr,lf,"Unsigned value 0ffffh output by putu: ",0
  1189.         mov    ax, 0ffffh
  1190.         putu
  1191.         print
  1192.         db    cr,lf,"Unsigned value 1 output by putu: ",0
  1193.         mov    ax, 1
  1194.         putu
  1195. ;
  1196.         print
  1197.         db    cr,lf,"Long value 0ffff1234 output by putL: ",0
  1198.         mov    ax, 1234h
  1199.         mov    dx, 0ffffh
  1200.         putl
  1201.         print    
  1202.         db    cr,lf,"Long value 01234ffff output by putL: ",0
  1203.         mov    dx, 1234h
  1204.         mov    ax, 0ffffh
  1205.         putl
  1206. ;
  1207.         print
  1208.         db    cr,lf,"Unsigned long value 1234ffff output by "
  1209.         db    "putUL: ",0
  1210.         putul
  1211.         print
  1212.         db    cr,lf,"Unsigned long value 0ffff1234 output by "
  1213.         db    "putUL: ",0
  1214.         mov    dx, 0ffffh
  1215.         mov    ax, 1234h
  1216.         putUL
  1217.         putcr
  1218. ;
  1219.         mov    cx, 10
  1220. islp1:        print
  1221.         db    "Outputting -2567 using a field width of ",0
  1222.         mov    ax, cx
  1223.         puti
  1224.         print
  1225.         db    " **",0
  1226.         mov    ax, -2567
  1227.         putisize
  1228.         print
  1229.         db    "** w/PutISize",cr,lf,0
  1230.         loop    islp1
  1231. ;
  1232.         mov    cx, 10
  1233. islp2:        print
  1234.         db    "Outputting -2567 using a field width of ",0
  1235.         mov    ax, cx
  1236.         puti
  1237.         print
  1238.         db    " **",0
  1239.         mov    ax, -2567
  1240.         putusize
  1241.         print
  1242.         db    "** w/PutUSize",cr,lf,0
  1243.         loop    islp2
  1244. ;
  1245.         mov    cx, 10
  1246. islp3:        print
  1247.         db    "Outputting -2567 using a field width of ",0
  1248.         mov    ax, cx
  1249.         puti
  1250.         print
  1251.         db    " **",0
  1252.         mov    ax, -2567
  1253.         mov    dx, 0ffffh
  1254.         putlsize
  1255.         print
  1256.         db    "** w/PutLSize",cr,lf,0
  1257.         loop    islp3
  1258.         print
  1259.         db    "Outputting 0ff001234h using PutLSize: ",0
  1260.         mov    dx, 0ff00h
  1261.         mov    ax, 1234h
  1262.         mov    cx, 10
  1263.         PutLSize
  1264.         putcr
  1265. ;
  1266.         mov    cx, 10
  1267. islp4:        print
  1268.         db    "Outputting -2567 using a field width of ",0
  1269.         mov    ax, cx
  1270.         puti
  1271.         print
  1272.         db    " **",0
  1273.         mov    ax, -2567
  1274.         mov    dx, 0ffffh
  1275.         putulsize
  1276.         print
  1277.         db    "** w/PutULSize",cr,lf,0
  1278.         loop    islp4
  1279.         print
  1280.         db    "Outputting 0ff001234h using PutULSize: ",0
  1281.         mov    dx, 0ff00h
  1282.         mov    ax, 1234h
  1283.         mov    cx, 10
  1284.         PutULSize
  1285.         putcr
  1286. ;
  1287. ;****************************************************************************
  1288. ;
  1289. ; Testing the PRINTF routine:
  1290. ;
  1291.         printf
  1292.         db    "This is a test of the printf routine w/o any "
  1293.         db    "operands.\n"
  1294.         db    "It tests the esc characters \\n, \\r, \\b, \\t, "
  1295.         db    "\0x0d, and \\\\.\n"
  1296.         db    "Test of \\r:\n"
  1297.         db    "Old line.\rNew line.\n"
  1298.         db    "Test of \t\ttab.\n"
  1299.         db    "Test of backspace\b\b\b\b\bs p a c e\n"
  1300.         db    "Test of return using \\0x0d:\n"
  1301.         db    "Old line.\0x0dNew line.\n\n",0
  1302. ;
  1303.         printf
  1304.         db    cr,lf
  1305.         db    "Test of integer output formats (using I):\n"
  1306.         db    "\%d\t\t-\t*%d*\n"
  1307.         db    "\%10d\t\t-\t*%10d*\n"
  1308.         db    "\%-10d\t\t-\t*%-10d*\n"
  1309.         db    "\%\\*10d\t\t-\t*%\*10d*\n"
  1310.         db    "\%\-\\*10d\t\t-\t*%-\*10d*\n"
  1311.         db    "\%^d\t\t-\t*%^d*\n"
  1312.         db    "\%10^d\t\t-\t*%10^d*\n"
  1313.         db    "\%-10^d\t\t-\t*%-10^d*\n"
  1314.         db    "\%\\*10^d\t\t-\t*%\*10^d*\n"
  1315.         db    "\%\-\\*10^d\t-\t*%-\*10^d*\n"
  1316.         db    0
  1317.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  1318. ;
  1319.         printf
  1320.         db    cr,lf
  1321.         db    "Test of unsigned integer output formats (using U):\n"
  1322.         db    "\%u\t\t-\t*%u*\n"
  1323.         db    "\%10u\t\t-\t*%10u*\n"
  1324.         db    "\%-10u\t\t-\t*%-10u*\n"
  1325.         db    "\%\\*10u\t\t-\t*%\*10u*\n"
  1326.         db    "\%\-\\*10u\t\t-\t*%-\*10u*\n"
  1327.         db    "\%^u\t\t-\t*%^u*\n"
  1328.         db    "\%10^u\t\t-\t*%10^u*\n"
  1329.         db    "\%-10^u\t\t-\t*%-10^u*\n"
  1330.         db    "\%\\*10^u\t\t-\t*%\*10^u*\n"
  1331.         db    "\%\-\\*10^u\t-\t*%-\*10^u*\n"
  1332.         db    0
  1333.         dd    u,u,u,u,u,pu,pu,pu,pu,pu
  1334. ;
  1335.         printf
  1336.         db    cr,lf
  1337.         db    "Test of unsigned long output formats (using UL):\n"
  1338.         db    "\%ul\t\t-\t*%lu*\n"
  1339.         db    "\%15lu\t\t-\t*%15lu*\n"
  1340.         db    "\%-15lu\t\t-\t*%-15lu*\n"
  1341.         db    "\%\\*15lu\t\t-\t*%\*15lu*\n"
  1342.         db    "\%\-\\*15lu\t-\t*%-\*15lu*\n"
  1343.         db    "\%^lu\t\t-\t*%^lu*\n"
  1344.         db    "\%15^lu\t\t-\t*%15^lu*\n"
  1345.         db    "\%-15^lu\t\t-\t*%-15^lu*\n"
  1346.         db    "\%\\*15^lu\t-\t*%\*15^lu*\n"
  1347.         db    "\%\-\\*15^lu\t-\t*%-\*15^lu*\n"
  1348.         db    0
  1349.         dd    ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
  1350. ;
  1351.         printf
  1352.         db    cr,lf
  1353.         db    "Test of long output formats (using L):\n"
  1354.         db    "\%ld\t\t-\t*%ld*\n"
  1355.         db    "\%15ld\t\t-\t*%15ld*\n"
  1356.         db    "\%-15ld\t\t-\t*%-15ld*\n"
  1357.         db    "\%\\*15ld\t\t-\t*%\*15ld*\n"
  1358.         db    "\%\-\\*15ld\t-\t*%-\*1ld*\n"
  1359.         db    "\%^ld\t\t-\t*%^ld*\n"
  1360.         db    "\%15^ld\t\t-\t*%15^ld*\n"
  1361.         db    "\%-15^ld\t\t-\t*%-15^ld*\n"
  1362.         db    "\%\\*15^ld\t-\t*%\*15^ld*\n"
  1363.         db    "\%\-\\*15^ld\t-\t*%-\*15^ld*\n"
  1364.         db    0
  1365.         dd    l,l,l,l,l,pl,pl,pl,pl,pl
  1366. ;
  1367.         printf
  1368.         db    cr,lf
  1369.         db    "Test of hexadecimal output (byte) using I:\n"
  1370.         db    "\%h\t\t-\t*%h*\n"
  1371.         db    "\%5h\t\t-\t*%5h*\n"
  1372.         db    "\%-5h\t\t-\t*%-5h*\n"
  1373.         db    "\%\\*5h\t\t-\t*%\*5h*\n"
  1374.         db    "\%\-\\*5h\t\t-\t*%-\*5h*\n"
  1375.         db    "\%^h\t\t-\t*%^h*\n"
  1376.         db    "\%5^h\t\t-\t*%5^h*\n"
  1377.         db    "\%-5^h\t\t-\t*%-5^h*\n"
  1378.         db    "\%\\*5^h\t\t-\t*%\*5^h*\n"
  1379.         db    "\%\-\\*5^h\t\t-\t*%-\*5^h*\n"
  1380.         db    0
  1381.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  1382. ;
  1383.         printf
  1384.         db    cr,lf
  1385.         db    "Test of hexadecimal output (word) using I:\n"
  1386.         db    "\%x\t\t-\t*%x*\n"
  1387.         db    "\%5x\t\t-\t*%5x*\n"
  1388.         db    "\%-5x\t\t-\t*%-5x*\n"
  1389.         db    "\%\\*5x\t\t-\t*%\*5x*\n"
  1390.         db    "\%\-\\*5x\t\t-\t*%-\*5x*\n"
  1391.         db    "\%^x\t\t-\t*%^x*\n"
  1392.         db    "\%5^x\t\t-\t*%5^x*\n"
  1393.         db    "\%-5^x\t\t-\t*%-5^x*\n"
  1394.         db    "\%\\*5^x\t\t-\t*%\*5^x*\n"
  1395.         db    "\%\-\\*5^x\t\t-\t*%-\*5^x*\n"
  1396.         db    0
  1397.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  1398. ;
  1399.         printf
  1400.         db    cr,lf
  1401.         db    "Test of hexadecimal output (long) using UL:\n"
  1402.         db    "\%lx\t\t-\t*%lx*\n"
  1403.         db    "\%15lx\t\t-\t*%15lx*\n"
  1404.         db    "\%-15lx\t\t-\t*%-15lx*\n"
  1405.         db    "\%\\*15lx\t\t-\t*%\*15lx*\n"
  1406.         db    "\%\-\\*15lx\t-\t*%-\*15lx*\n"
  1407.         db    "\%^lx\t\t-\t*%^lx*\n"
  1408.         db    "\%15^lx\t\t-\t*%15^lx*\n"
  1409.         db    "\%-15^lx\t\t-\t*%-15^lx*\n"
  1410.         db    "\%\\*15^lx\t-\t*%\*15^lx*\n"
  1411.         db    "\%\-\\*15^lx\t-\t*%-\*15^lx*\n"
  1412.         db    0
  1413.         dd    ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
  1414. ;
  1415.         printf
  1416.         db    cr,lf
  1417.         db    "Test of character output using S:\n"
  1418.         db    "\%c\t\t-\t*%c*\n"
  1419.         db    "\%5c\t\t-\t*%5c*\n"
  1420.         db    "\%-5c\t\t-\t*%-5c*\n"
  1421.         db    "\%\\*5c\t\t-\t*%\*5c*\n"
  1422.         db    "\%\-\\*5c\t\t-\t*%-\*5c*\n"
  1423.         db    "\%^c\t\t-\t*%^c*\n"
  1424.         db    "\%5^c\t\t-\t*%5^c*\n"
  1425.         db    "\%-5^c\t\t-\t*%-5^c*\n"
  1426.         db    "\%\\*5^c\t\t-\t*%\*5^c*\n"
  1427.         db    "\%\-\\*5^c\t\t-\t*%-\*5^c*\n"
  1428.         db    0
  1429.         dd    s,s,s,s,s,ps,ps,ps,ps,ps
  1430. ;
  1431.         printf
  1432.         db    cr,lf
  1433.         db    "Test of string output using s:\n"
  1434.         db    "\%s\t\t-\t*%s*\n"
  1435.         db    "\%15s\t\t-\t*%15s*\n"
  1436.         db    "\%-15s\t\t-\t*%-15s*\n"
  1437.         db    "\%\\*15s\t\t-\t*%\*15s*\n"
  1438.         db    "\%\-\\*15s\t\t-\t*%-\*15s*\n"
  1439.         db    "\%^s\t\t-\t*%^s*\n"
  1440.         db    "\%15^s\t\t-\t*%15^s*\n"
  1441.         db    "\%-15^s\t\t-\t*%-15^s*\n"
  1442.         db    "\%\\*15^s\t\t-\t*%\*15^s*\n"
  1443.         db    "\%\-\\*15^s\t-\t*%-\*15^s*\n"
  1444.         db    0
  1445.         dd    s,s,s,s,s,ps,ps,ps,ps,ps
  1446. ;
  1447. ;****************************************************************************
  1448. ;
  1449. ; Test the input routines here.
  1450. ;
  1451.         print
  1452.         db    "Testing GETC- Press any key: ",0
  1453.         getc
  1454.         print
  1455.         db    cr,lf,"You pressed: '",0
  1456.         putc
  1457.         print
  1458.         db    "' : ",0
  1459.         putw
  1460.         print
  1461.         db    cr,lf,"Testing GetcStdIn- Press any key:",0
  1462.         GetcStdIn
  1463.         print
  1464.         db    cr,lf,"You pressed: '",0
  1465.         putc
  1466.         print
  1467.         db    "' : ",0
  1468.         putw
  1469.         print
  1470.         db    cr,lf,"Testing GetcBIOS- Press any key:",0
  1471.         getcBIOS
  1472.         print
  1473.         db    cr,lf,"You pressed: '",0
  1474.         putc
  1475.         print
  1476.         db    "' : ",0
  1477.         putw
  1478. ;
  1479.         print
  1480.         db    cr,lf,"Redirecting input, reading: ",0
  1481.         lesi    ReturnA
  1482.         SetInAdrs
  1483.         getc
  1484.         print
  1485.         db    cr,lf,"Getc returned: '",0
  1486.         putc
  1487.         print
  1488.         db    "' : ",0
  1489.         putw
  1490.         print
  1491.         db    cr,lf,"Pushing address, changing to 'B': ",0
  1492.         lesi    ReturnB
  1493.         PushInAdrs
  1494.         getc
  1495.         print
  1496.         db    cr,lf,"Getc returned: '",0
  1497.         putc
  1498.         print
  1499.         db    "' : ",0
  1500.         putw
  1501.         print
  1502.         db    cr,lf,"Popping address: ",0
  1503.         PopInAdrs
  1504.         cmp    di, offset ReturnB
  1505.         jne    BadPopIn
  1506.         mov    di, es
  1507.         cmp    di, seg ReturnB
  1508.         je    GoodPopIn
  1509. BadPopIn:    print
  1510.         db    cr,lf,"Did not return the proper address",cr,lf,0
  1511. GoodPopIn:    print
  1512.         db    cr,lf,"Popping address again, should read from kbd: "
  1513.         db    0
  1514.         PopInAdrs
  1515.         getc
  1516.         print
  1517.         db    cr,lf,"Getc returned: '",0
  1518.         putc
  1519.         print
  1520.         db    "' : ",0
  1521.         putw
  1522.         putcr
  1523. ;
  1524. ;****************************************************************************
  1525. ;
  1526. ; Test GETS here:
  1527. ;
  1528.         print
  1529.         db    "Testing GETS, enter a line of text: ",0
  1530.         gets
  1531.         jnc    goodgets
  1532.         print
  1533.         db    "Bad gets call",cr,lf,0
  1534. ;
  1535. goodgets:    print
  1536.         db    "You entered: ",0
  1537.         puts
  1538.         putcr
  1539. ;
  1540. ;
  1541. ;***************************************************************************
  1542. ;
  1543. ;
  1544. ;
  1545. Quit:        mov     ah, 4ch
  1546.         int     21h
  1547. ;
  1548. ;
  1549. Main        endp
  1550. ;
  1551. ;
  1552. dblchars    proc    far
  1553.         putcstdout
  1554.         putcstdout
  1555.         ret
  1556. dblchars    endp
  1557. ;
  1558. ;
  1559. ReturnA        proc    far
  1560.         mov    ax, "A"
  1561.         ret
  1562. ReturnA        endp
  1563. ;
  1564. ReturnB        proc    far
  1565.         mov    ax, "B"
  1566.         ret
  1567. ReturnB        endp
  1568. ;
  1569. ;
  1570. ; Printset- Prints the characters in the set passed in es:di
  1571. ;
  1572. PrintSet    proc
  1573.         push    es
  1574.         push    ds
  1575.         push    di
  1576.         push    si
  1577.         push    dx
  1578.         push    ax
  1579. ;
  1580.         mov    dx, es        ;dx:si := es:di
  1581.         mov    si, di
  1582. ;
  1583.         createsets
  1584.         copyset
  1585. PrLoop:        rmvitem
  1586.         cmp    al, 0
  1587.         jz    PrDone
  1588.         putc
  1589.         jmp    PrLoop
  1590. ;
  1591. PrDone:        free
  1592.         pop    ax
  1593.         pop    dx
  1594.         pop    si
  1595.         pop    di
  1596.         pop    ds
  1597.         pop    es
  1598.         ret
  1599. PrintSet    endp
  1600. ;
  1601. ;
  1602. cseg            ends
  1603. ;
  1604. ;
  1605. ; Allocate a reasonable amount of space for the stack (2k).
  1606. ;
  1607. sseg        segment    para stack 'stack'
  1608. stk        db    256 dup ("stack   ")
  1609. sseg        ends
  1610. ;
  1611. ;
  1612. ;
  1613. ; zzzzzzseg must be the last segment that gets loaded into memory!
  1614. ;
  1615. zzzzzzseg    segment    para public 'zzzzzz'
  1616. LastBytes    db    16 dup (?)
  1617. zzzzzzseg    ends
  1618.         end    Main
  1619.